|
From the type class counter of the last chapter some more specialized counters can be derived. Letīs assume we need the following counters:
For Implementation of these new counters, you donīt have to repeat the declarations which are already made in the class counter. The existing attributes and methods will be inherited and just new or modified functionalities or properties have to be specified. The keywords new ... with are used to derive classes. The following example shows the derivation of the counter classes: |
type up_down_counter is
address_counter and up_down_counter are derived from counter. They inherit all attributes and methods from parent class counter. address_counter redefines the count_up method, up_down_counter defines a new method count_down. |